//
//  AppDelegate.m
//  5-24
//
//  Created by mac on 16-5-24.
//  Copyright (c) 2016年 ZHD. All rights reserved.
//

#import "AppDelegate.h"
#import "ViewController.h"
#import "TwoViewController.h"
#import "ThereViewController.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    CGRect rect=[UIScreen mainScreen].bounds;
    _window=[[UIWindow alloc]initWithFrame:rect];
    ViewController *con=[ViewController new];
    TwoViewController *con1=[TwoViewController new];
    ThereViewController *con2=[ThereViewController new];
    
    
    
    
    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:con];//导航控制器
    nav.tabBarItem.title = @"主页";//在下面创建翻页导航栏
    nav.tabBarItem.image = [UIImage imageNamed:@"home"];//让它返回主界面
    
    UINavigationController *nav1= [[UINavigationController alloc]initWithRootViewController:con1];
    nav1.tabBarItem.title = @"第一页";
    nav1.tabBarItem.image = [UIImage imageNamed:@"more"];
    
    UINavigationController *nav2=[[UINavigationController alloc]initWithRootViewController:con2];
    nav2.tabBarItem.title = @"第二页";
    nav2.tabBarItem.image = [UIImage imageNamed:@"my"];
    
    UITabBarController *tab = [UITabBarController new];//在下面创建可以翻页的的导航栏，这句包裹着控制翻页，并包裹着上面的导航栏
    tab.viewControllers = @[nav1,nav,nav2];
    tab.selectedIndex = 1;//默认是显示第一个页面，现在是第二个页面
    
    
    [tab.tabBar.items.firstObject setBadgeValue:@"New"];//角标
    //tab.tabBar.items.firstObject.badgeValue = @"5";
    
    tab.tabBar.tintColor = [UIColor redColor];//下面导航栏的图标颜色
    
    
    
    
    _window.rootViewController = tab;//nav;
    [_window makeKeyAndVisible];//让它成为关键的窗口
    return YES;
}
							
- (void)applicationWillResignActive:(UIApplication *)application
{
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
    NSLog(@"应用程序正在启动");
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application
{
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
